package com.handydata.antifraud.channel.outbound;

import com.handydata.antifraud.to.RiskOutputTO;
import com.handydata.antifraud.vo.riskres.RiskOutputVO;
import com.handydata.common.convert.CommonBeanConvertor;
import lombok.extern.log4j.Log4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Objects;

@Component
@Log4j
public class DataPusher {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void push(RiskOutputTO riskOutputTO) {
        RiskOutputVO riskOutputVO = CommonBeanConvertor.convert(riskOutputTO, RiskOutputVO.class);
        if(Objects.isNull(riskOutputVO)){
            log.error("反欺诈系统处理结果错误:{}" + riskOutputVO);
            return;
        }
        log.info("开始推送上行数据>>>>>>>>>>>>>>>>>>>>>{}"+riskOutputVO);
        rabbitTemplate.convertAndSend("exchange-3", "info",riskOutputVO);
        log.info("上行推送结束>>>>>>>>>>>>>>>>>>>>>>>>>");
    }
}
